function [trans,gamma,sigma]=translate_params(theta_hat,nobeta,nosigma,fs_sims,rf_sims)

%Get Parameters
b_mu=exp(theta_hat(1))/(1+exp(theta_hat(1)));
b_alpha=theta_hat(2);
t=3;
if nobeta==0
   b_beta=theta_hat(t); t=t+1; 
else
   b_beta=0;
end
if nosigma==0
   b_sigma=exp(theta_hat(t)); t=t+1;
else
   b_sigma=0;
end
b_mn_gamma=theta_hat(t); t=t+1;
b_sd_gamma=exp(theta_hat(t)); t=t+1;
w_mu=exp(theta_hat(t))/(1+exp(theta_hat(t))); t=t+1;
w_alpha=theta_hat(t); t=t+1;
if nobeta==0
   w_beta=theta_hat(t); t=t+1;
else
   w_beta=0;
end
if nosigma==0
   w_sigma=exp(theta_hat(t)); t=t+1;
else
   w_sigma=0;
end
w_mn_gamma=theta_hat(t); t=t+1;
w_sd_gamma=exp(theta_hat(t));
corr_gamma=(exp(theta_hat(t))-1)/(exp(theta_hat(t))+1); t=t+1;
corr_sigma=(exp(theta_hat(t))-1)/(exp(theta_hat(t))+1); t=t+1;
gamma_V=[b_sd_gamma^2,corr_gamma*b_sd_gamma*w_sd_gamma;corr_gamma*b_sd_gamma*w_sd_gamma,w_sd_gamma^2];
sigma_V=[b_sigma^2,corr_sigma*b_sigma*w_sigma;corr_sigma*b_sigma*w_sigma,w_sigma^2];

trans=zeros(18,1);

%Pretrial Misconduct Rate
trans(1)=b_mu;
trans(7)=w_mu;

%Signal Quality
gamma=[b_mn_gamma,w_mn_gamma]+fs_sims*chol(gamma_V); 
kappa=[b_alpha,w_alpha]+repmat([b_beta,w_beta],length(rf_sims),1).*gamma;
if nosigma==0
    kappa=kappa+rf_sims*chol(sigma_V);
end

sigma=exp(kappa);
tau=1./sigma;
mn_tau=mean(tau);
trans(2)=mn_tau(1);
trans(8)=mn_tau(2);
if nosigma==0
    sd_tau=std(tau);
    trans(3)=sd_tau(1);
    trans(9)=sd_tau(2);
end

%b
L=length(sigma);
pi=zeros(L,2);
b=zeros(L,2);
for l=1:L
    pi(l,1)=signalcdf(gamma(l,1),b_mu,sigma(l,1));
    pi(l,2)=signalcdf(gamma(l,2),w_mu,sigma(l,2));
    b(l,1)=1/(1+((1-b_mu)/b_mu)*exp((0.5-gamma(l,1))/sigma(l,1)^2));
    b(l,2)=1/(1+((1-w_mu)/w_mu)*exp((0.5-gamma(l,2))/sigma(l,2)^2));
end
if nosigma==0
    temp=cov(tau(:,1),b(:,1));
    trans(4)=temp(1,2);
    temp=cov(tau(:,2),b(:,2));
    trans(10)=temp(1,2);
end
mn_b=mean(b);
trans(5)=mn_b(1);
trans(11)=mn_b(2);
sd_b=std(b);
trans(6)=sd_b(1);
trans(12)=sd_b(2);
for t=1:6
   trans(12+t)=trans(6+t)-trans(t); 
end

